/**
 * Created by huangxuehua on 2017/12/6.
 */
//$(".goBack").click(function(){
//    window.history.go(-1)
//});

var xpHome = new Vue({
    el:'#app',
    data:{
        imgBaseUrl: nUrls.imgBaseUrl,//图片路径
        padded:false,
        showGoodsList:[],//推荐信息列表
    },
    methods: {
        getImage:function(url){//加载图片  处理 url为空 加载出错
            if(url){
                return xpHome.imgBaseUrl+url;
            }
        },
        getGoodsInfo:function(){
            $.ajax({
                url: nUrls.getThreeGoodsInfo,
                type:'post',
                success:function(data){
                    var result = eval('('+data+')');
                    if(result && result.code == 200){
                        //console.log(result)
                        xpHome.showGoodsList = result.data;
                        console.log(xpHome.showGoodsList);
                    }
                },
                error:function(){
                    console.log("没有更多信息")
                }
            });
        },
        goDetail: function (good_id) {//到商品详情页
            window.location.href = "../detail/goods_detail.html?id="+good_id;
        },
        goIndex:function(){  //到首页
            window.location.href = "../../index.html";
        },
        goOrderInfo:function(pageType){ //到订单详情页
            window.location.href = "../my_center_detail/indent/indent.html?flag="+pageType;
        },
        goOnLine:function(){  //断网刷新
            nUtils.onLine();
        }
    }
});
$(function(){
    xpHome.getGoodsInfo();
    window.localStorage.setItem("couponInfo","")//清空Buy页面优惠券信息

    //if(sessionStorage.opened){    //sessionStorage缓存
        //console.log('窗口是刷新页面,不是新打开')
        //$("#imgBg1").hide();
        //$("#imgBg1").css("display","none");
        //$("#body1").show();
        //$("#suBody").css("display","block");
    //}else{
        //console.log('窗口是新打开')
        $("#imgBg1").css("display","block");
        $("#suBody").css("display","block");
    //}
    //sessionStorage.setItem('opened','true');
    touchMoveCant("#imgBg1");
})

$(".closeBtn").click(function(){ //点击关闭提示框
    $("#imgBg1").css("display","none");
});
$("#goActivity").click(function(){
    window.location.href="../activity.html"
})
//
//
//$("#coverPic").click(function(){  //遮罩层显示
//    $("#shareDiv").show();
//    document.body.scrollTop = 0;
//    document.documentElement.scrollTop = 0;
//    $("#suBody").css("overflow","hidden");
//    $("#shareDiv").css("display","block");
//
//    $("#shareDiv").css({
//        "position":"absolute",
//        "top":"0",
//        "width":"100%",
//        "height":"100%",
//        "background":"#555",
//        "opacity":"0.6"
//    })
//    touchMoveCant("#shareDiv");
//});
function touchMoveCant(ele){//ios 等其他型号手机 滑动问题
    document.querySelector(ele).addEventListener("touchmove", function(e){
        e.preventDefault();
    });
}
//$("#shareDiv").click(function(){
//    $("#shareDiv").hide();
//    $("#suBody").css("overflow","auto");
//})
//$("#fenXiang").click(function(){ //遮罩层隐藏，并分享
//    $("#shareDiv").hide();
//
//})